import * as TYPES from "../action-types";
import { Map } from "immutable";
let initState = Map({
  rankTitList: [], //榜单数据
  rankCurrenIdx: 0, //当前选中的新歌排行榜
  rankPlayObj: {}, //选中排行榜-头部数据
  rankPrivileges: [], //排行榜歌曲列表
});
function rank(state = initState, action) {
  const { type, payload } = action;
  switch (type) {
    case TYPES.RANK_TIT_LIST:
      return state.set("rankTitList", payload);
    case TYPES.RANK_CURRENT_IDX:
      return state.set("rankCurrenIdx", payload);
    case TYPES.RANK_DETAIL_DATA:
      const { playlist, privileges } = payload;
      return state
        .set("rankPrivileges", privileges)
        .set("rankPlayObj", playlist);

    default:
      return state;
  }
}

export default rank;
